﻿#include "workstate.h"
#include "common_log.h"
#include "component_data.h"

WorkState::WorkState(QObject *parent)
	: SystemStateBase(parent)
{
}

WorkState::~WorkState()
{
}


bool WorkState::InitState()
{
	/*m_task = SystemDialogManger::GetTaskCheckDialog();
	if (!m_task->InitDialog()) {
		log_error("task check dialog init failed");
		return false;
	}*/
	return true;
}

bool WorkState::Running()
{
	stopFlag = false;
	log_trace("***************SYSTEM STATE WORK***************");
	m_writer->WriteTraceJournal(u8"进入工作状态，开始启动业务");
	//m_task->ExecDialog();
	return true;
}

void WorkState::ComponentEvnetHandle(int event)
{
	if (stopFlag) {
		return;
	}
	log_trace("reviece event[{}]", event);

	if ((int)ComponentEvent::system_event_reset == event) {
		m_writer->WriteTraceJournal("工作模式下，无法执行复位操作");
		return;
	}
	if ((int)ComponentEvent::system_event_start == event) {
		m_writer->WriteTraceJournal("系统已经启动，无法执行启动操作");
		return;
	}

	if ((int)ComponentEvent::system_event_stop == event) {
		m_writer->WriteWarnJournal(QString(u8"收到停止信号，切换到停止模式"));
	}
	emit ChangeSystemState(3);
}
